package com.example.appcomedores;

import com.example.appcomedoresproject.R;

import android.R.*;
import android.app.Activity;
import android.content.Intent;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Toast;

/**
 * Created by Administrador on 31/08/13.
 */
public class Actualizar extends Activity implements View.OnClickListener{
    // Array of options --> ArrayAdapter --> ListView
	 
    //List view: {views: da_items.xml}
    Button btnGuardar,btnEliminar;
    EditText etActUser;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.actividad_actualizar);

        Bundle bundle = getIntent().getExtras();
        etActUser = (EditText)findViewById(R.id.etActUser);
        etActUser.setText(bundle.getString("id"));
       

        btnGuardar=(Button)findViewById(R.id.btnGuardar);
        btnGuardar.setOnClickListener(this);

        btnEliminar=(Button)findViewById(R.id.btnEliminar);
        btnEliminar.setOnClickListener(this);
        if(bundle.getBoolean("admin")){
        	btnEliminar.setEnabled(true);
        }
        else{
        	btnEliminar.setEnabled(false);
        }

        Spinner sp  =(Spinner)findViewById(R.id.spinner);
        ArrayAdapter adapter = ArrayAdapter.createFromResource(
                this,R.array.versiones,android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        sp.setAdapter(adapter);

        /*sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){

            public void onItemSelected(AdapterView<?> parentView, View selectedItemView,
                                       int position, long id){
                Toast.makeText(parentView.getContext(), "Has seleccionado " +
                        parentView.getItemAtPosition(position).toString(), Toast.LENGTH_LONG).show();
            }
            public void onNothingSelected(AdapterView<?> parentView){

            }
        });*/
    }

    @Override
    public void onClick(View arg0){
        switch(arg0.getId()){
            case R.id.btnGuardar:
                //Toast Presenta un cuadro de dialogo
                Toast t=Toast.makeText(this,"Registro Modificado",Toast.LENGTH_SHORT);
                t.show();
                break;
            case R.id.btnEliminar:
                //Toast Presenta un cuadro de dialogo
                Toast t1=Toast.makeText(this,"Registro Eliminado",Toast.LENGTH_SHORT);
                t1.show();
                break;
        }
    }
}